import {request} from "@/plugins/request"
// 全部
export const getArticles = params => {
  return request({
    method: "GET",
    url: "/api/articles",
    params
  })
}
// 个人
export const getFeedArticles = params => {
  return request({
    method: "GET",
    url: "/api/articles/feed",
    params
  })
}
// 收藏
export const addFavorite = slug => {
  return request({
    method: "POST",
    url: `/api/articles/${slug}/favorite`
  })
}
// 取消收藏
export const deleteFavorite = slug => {
  return request({
    method: "DELETE",
    url: `/api/articles/${slug}/favorite`
  })
}
// 关注
export const addFollow = slug => {
  return request({
    method: "POST",
    url: `/api/profiles/${slug}/follow`
  })
}
// 取关
export const deleteFollow = slug => {
  return request({
    method: "DELETE",
    url: `/api/profiles/${slug}/follow`
  })
}
// 文章详情
export const getArticle = slug => {
  return request({
    method: "GET",
    url: `/api/articles/${slug}`
  })
}
// 获取评论
export const getComments = slug => {
  return request({
    method: "GET",
    url: `/api/articles/${slug}/comments`
  })
}
// 提交评论
export const addComments = (slug,data) => {
  return request({
    method: "post",
    url: `/api/articles/${slug}/comments`,
    data
  })
}
// 删除评论
export const deleteComments = (slug,id) => {
  return request({
    method: "delete",
    url: `/api/articles/${slug}/comments/${id}`
  })
}
// 删除文章
export const deleteArticle = slug => {
  return request({
    method: "delete",
    url: `/api/articles/${slug}`
  })
}

// 发布文章
export const addArticle = data => {
  return request({
    method: "POST",
    url: '/api/articles',
    data
  })
}